/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPanelTool.java
 *
 * Created on Dec 5, 2011, 9:03:22 AM
 */
package management;

import java.awt.event.ActionEvent;

/**
 *
 * @author buer
 */
public class JPanelTool extends javax.swing.JPanel {

    /** Creates new form JPanelTool */
    public JPanelTool(JPanelWordTable jPanelWordTable) {
        this.jPanelWordTable = jPanelWordTable;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBSave = new javax.swing.JButton();
        jBCancel = new javax.swing.JButton();
        jCBFilter = new javax.swing.JComboBox();

        setPreferredSize(new java.awt.Dimension(600, 50));

        jBSave.setText("保存修改");
        jBSave.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBSaveMouseClicked(evt);
            }
        });
        jBSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSaveActionPerformed(evt);
            }
        });

        jBCancel.setText("取消修改");
        jBCancel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jBCancelMouseClicked(evt);
            }
        });

        jCBFilter.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Rate 1", "Rate 2", "Rate 3", "Rate 4", "Rate 5", "Rate All" }));
        jCBFilter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCBFilterActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(jBSave)
                .addGap(34, 34, 34)
                .addComponent(jBCancel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 204, Short.MAX_VALUE)
                .addComponent(jCBFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBCancel)
                    .addComponent(jBSave)
                    .addComponent(jCBFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(17, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jBSaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBSaveMouseClicked
        // TODO add your handling code here:
        jPanelWordTable.saveWordTable();
    }//GEN-LAST:event_jBSaveMouseClicked

    private void jBCancelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBCancelMouseClicked
        // TODO add your handling code here:
        //取消编辑之后直接刷新屏幕重新显示
        jPanelWordTable.createWordList(jCBFilter.getSelectedIndex());
        jPanelWordTable.updateUI();
    }//GEN-LAST:event_jBCancelMouseClicked

private void jCBFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBFilterActionPerformed
    if (evt.getSource() == jCBFilter) {
        jPanelWordTable.createWordList(jCBFilter.getSelectedIndex());
        jPanelWordTable.updateUI();
    }
    // TODO add your handling code here:
}//GEN-LAST:event_jCBFilterActionPerformed

    private void jBSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSaveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jBSaveActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBCancel;
    private javax.swing.JButton jBSave;
    private javax.swing.JComboBox jCBFilter;
    // End of variables declaration//GEN-END:variables
    private JPanelWordTable jPanelWordTable;
}
